<?php
/******************************************************
v4 - Management Framework
Copyright (C) 2008  Gary Taylor, gMerc Incorporation
http://www.gmerc.com/v4/

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

gary@gmerc.com
******************************************************/
class sitebox extends websites {
  function liftbox_start($containername,$wid='',$hei='') {
    $ret='';
    $ret.='<div id="'.$containername.'" style="visibility: hidden;position: absolute;left: 0px;top: 0px;width:100%;height:100%;text-align:center;z-index: 1000;';
    $ret.='background-image:url(/art/background-trans.png);';
    $ret.='">';
    $ret.='<div style="';
    if ($wid!='') { $ret.='width:'.$wid.';'; }
    if ($hei!='') { $ret.='height:'.$hei.';'; }
    $ret.='margin:25px auto;background-color: #fff;border:1px solid #000;padding:0px;text-align:center;">';
  return $ret;
  }
  function liftbox_end() {
    $ret='';
    $ret.='</div></div>';
  return $ret;
  }
  function liftbox_headline($containername,$headline='') {
    global $masterclass;
    
    $ret='';
    $ret.='<table width="100%" cellpadding="2" cellspacing="0" border="0"><tr>';
    $ret.='<td class="sitebox_headline" id="'.$containername.'_headline">'.$headline.'</td>';
    $ret.='<td class="sitebox_headline" width="10" style="cursor:pointer;" OnClick="hide_overlay(document.getElementById(\''.$containername.'\'));"><img src="'.$masterclass->mainconfig['dir'].'art/cross.png" border="0" alt="Close" title=" Close "></td>';
    $ret.='</tr></table>';
  return $ret;
  }
  
  function sitebox_start($wid='197',$hei='') {
    $ret='';
    $ret.='<table width="'.$wid.'" height="'.$hei.'" border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td style="border:1px solid;">';
    return $ret;
  }
  function sitebox_headline($display,$collapseid='') {
    $ret='';
    $ret.='<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr class="sitebox_headline">';
    $ret.='<td style="padding-left:2px;padding-right:2px;border-bottom:1px solid;border-color:#000000;">'.$display.'</td>';
    if ($collapseid!='') { $ret.='<td style="text-align:right;border-bottom:1px solid;border-color:#000000;"><input type="button" value="O" OnClick="switchframe(document.getElementById(\''.$collapseid.'\'),-1,-1)"></td>'; }
    $ret.='</tr></table>';
    return $ret;
  }
  function sitebox_navigation($display) {
    $ret='';
    $ret.='<table width="100%" cellpadding="3" cellspacing="0" border="0"><tr class="sitebox_navigation">';
    $ret.='<td style="padding-left:2px;padding-right:2px;border-top:1px solid;border-bottom:1px solid;border-color:#000000;">'.$display.'</td>';
    $ret.='</tr></table>';
    return $ret;
  }
  function sitebox_end() {
    $ret='';
    $ret.='</td></tr></table>';
    return $ret;
  }
  function sitebox_contentstart() {
    $ret='';
    $ret.='</td></tr></table>';
    return $ret;
  }
  function sitebox_contentend() {
    $ret='';
    $ret.='</td></tr></table>';
    return $ret;
  }
  function sitebox_pageheader($display,$collapseid='') {
    $ret='';
    $ret.='<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr class="sitebox_pageheader">';
    $ret.='<td style="padding-left:2px;padding-right:2px;border-bottom:1px solid;border-color:#000000;">'.$display.'</td>';
    $ret.='</tr></table>';
    return $ret;
  }
  function sitebox_vspacer($hei='10px') {
    $ret='';
    $ret.='<div style="height:'.$hei.';font-size:1px;">&nbsp;</div>';
    return $ret;
  }
  function sitebox_hspacer($wid='10px') {
    $ret='';
    $ret.='<div style="width:'.$wid.';font-size:1px;">&nbsp;</div>';
    return $ret;
  }
  
  function sitebox_linklist() {
  global $masterclass;

    $ret='';

    $ret.='<div style="sitebox_naviation"><a href="'.$masterclass->mainconfig['dir'].'">Main Page</a></div><br>';

    $arrparents=array();
    $arrcategories=array();
    $preurl=$masterclass->websiteconfig['pictures_photo_dir'];

    if (is_dir($masterclass->websiteconfig['pictures_photographer_orig'])) {
      $rootpath=$masterclass->websiteconfig['pictures_photographer_orig'];
      $arrparents=$masterclass->allclasses['dir_categories']->fetch_dir_category_parents($rootpath);
      $arrcategories = $masterclass->allclasses['dir_categories']->fetch_dir_category_children($rootpath,'1');
    }

    $ret.='<table width="100%" align="center" cellpadding="1" cellspacing="0" class="sitebox_navigation">';

    $currentprefix='';
    $lastparentid='';
    $curparentid='';

    while (!empty($arrcategories)) {

      if ($arrcategories[0]=='removedash') { $ret.='</table></td></tr>';$currentprefix=substr($currentprefix,0,strlen($currentprefix)-6);array_shift($arrcategories);array_shift($arrcategories);continue; }
      $categoryname=$arrcategories[0];
      $curpath=$rootpath.$arrcategories[0].'/';

      if ($masterclass->allclasses['dir_categories']->get_dir_children_count($curpath)>0) {
        $ret.='<tr valign="top"><td width="100%" valign="middle" class="sitebox_navigation" style="padding-left:1px;padding-right:1px;cursor: pointer;';
        $ret.='"><nobr>'.$currentprefix.'<span  OnClick="switchframe(document.getElementById(\'categorylist'.str_replace(" ","",$arrcategories[0]).'\'));SetCookie(\'categorylist'.str_replace(" ","",$arrcategories[0]).'\',document.getElementById(\'categorylist'.str_replace(" ","",$arrcategories[0]).'\').style.display,null,\'/\');">+</span>&nbsp;<a href="'.$preurl.$categoryname.'/">';
        if ($arrcategories[0]==stripslashes($_REQUEST['photopath'])) { $ret.='<b>'; }
        if (strstr($categoryname,"/")) { $ret.=substr(strrchr($categoryname,"/"),1); } else { $ret.=$categoryname; }
        if ($arrcategories[0]==stripslashes($_REQUEST['photopath'])) { $ret.='</b>'; }
        $ret.='</a></nobr></td></tr><tr valign="top"><td colspan="2" valign="middle" class="sitebox_navigation" style="padding-left:1px;padding-right:1px;">';
        $ret.='<table name="categorylist'.str_replace(" ","",$arrcategories[0]).'" id="categorylist'.str_replace(" ","",$arrcategories[0]).'" width="100%" align="center" cellpadding="1" cellspacing="0" class="sitebox_contents" ';
        if (!isset($arrparents) || empty($arrparents) || !in_array($arrcategories[0],$arrparents)) {
          if (!strstr($_REQUEST['photopath'],$categoryname.'/') && (!isset($_COOKIE['categorylist'.str_replace(" ","",$arrcategories[0])]) || $_COOKIE['categorylist'.str_replace(" ","",$arrcategories[0])]=='none')) { $ret.=' style="display:none;" '; }
        }
        $ret.='>';

/*
if (in_array($arrcategories[0],$arrparents) || $arrcategories[0]==$this->sessioncategoryid) {
  $ret.="<script language=\"javascript\">\n";
  $ret.='SetCookie(\'categorylist'.str_replace(" ","",$arrcategories[0]).'\',\'\',null,\'/\');';
  $ret.="\n";
  $ret.="</script>\n";
 }
 */

        array_unshift($arrcategories,$arrcategories[0]);
        $arrcategories[0]='removedash';

        $currentprefix.='&nbsp;';

        $dir = dir($curpath);
        while ($file = $dir->read()) {
          if($file != "." && $file != "..") {
            if (is_dir($curpath.$file)) {
            array_unshift($arrcategories,$categoryname.'/'.$file);
            }
          }
        }
        $dir->close();

      } else {
        $ret.='<tr valign="top" OnClick=""><td width="100%" valign="middle" class="sitebox_navigation" style="padding-left:3px;padding-right:1px;cursor: pointer;';
        if ($arrcategories[0]==stripslashes($_REQUEST['photopath'])) { $ret.='background-color:#666666;'; }
        $ret.='"><nobr>'.$currentprefix.'&#149;&nbsp;<a href="'.$preurl.$categoryname.'/">';
        if ($arrcategories[0]==stripslashes($_REQUEST['photopath'])) { $ret.='<b>'; }
        if (strstr($categoryname,"/")) { $ret.=substr(strrchr($categoryname,"/"),1); } else { $ret.=$categoryname; }
        if ($arrcategories[0]==stripslashes($_REQUEST['photopath'])) { $ret.='</b>'; }
        $ret.='</a></nobr></td></tr>';
        array_shift($arrcategories);
      }

      if ($arrcategories[0]=='removedash') { $ret.='</table></td></tr>';$currentprefix=substr($currentprefix,0,strlen($currentprefix)-6);array_shift($arrcategories);array_shift($arrcategories); }
    }
    $ret.='</table>';
  return $ret;
  }
  
}
?>